import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    redirect: '/homePage'
  },
  {
    path: "/login",
    name: "login",
    component: () => import(/* webpackChunkName: "pc" */ "../views/login.vue"),
  },

  {
    path: "/home",
    name: "Home",
    component: Home,
    children: [
      {
        path: '/homePage',
        name: 'homePage',
        component: () => import(/* webpackChunkName: "pc" */ '../views/index.vue')
      },
      {
        path: '/mainPic',
        name: 'mainPic',
        component: () => import(/* webpackChunkName: "main" */ '../views/main/mainPic.vue')
      },
      {
        path: '/orders',
        name: 'orderList',
        component: () => import(/* webpackChunkName: "order" */ '../views/order/orderList.vue')
      },
      // 文章 视频列表
      {
        path: '/contentList',
        name: 'contentList',
        component: () => import(/* webpackChunkName: "content" */ '../views/content/contentList.vue')
      },
      {
        path: '/articlemanage',
        name: 'articlemanage',
        component: () => import(/* webpackChunkName: "content" */ '../views/content/ArticleManage.vue')
      },
      {
        path: '/ArticleClassifi',
        name: 'ArticleClassifi',
        component: () => import(/* webpackChunkName: "content" */ '../views/content/ArticleClassifi.vue')
      },
      {
        path: '/ArticleResponse',
        name: 'ArticleResponse',
        component: () => import(/* webpackChunkName: "content" */ '../views/content/ArticleResponse.vue')
      },
      {
        path: '/contentTagList',
        name: 'contentTagList',
        component: () => import(/* webpackChunkName: "content" */ '../views/content/contentTagList.vue')
      },
      {
        path: '/categroyList',
        name: 'categroyList',
        component: () => import(/* webpackChunkName: "content" */ '../views/product/categroyList.vue')
      },

      {
        path: '/addProduct',
        name: 'addProduct',
        component: () => import(/* webpackChunkName: "product" */ '../views/product/addProduct.vue')
      },
      {
        path: '/zhuanquList',
        name: 'zhuanquList',
        component: () => import(/* webpackChunkName: "product" */ '../views/product/zhuanquList.vue')
      },
      {
        path: '/specials',
        name: 'specials',
        component: () => import(/* webpackChunkName: "product" */ '../views/product/specials.vue')
      },
      {
        path: '/productComment',
        name: 'comment',
        component: () => import(/* webpackChunkName: "product" */ '../views/product/comment.vue')
      },
      {
        path: '/answerList',
        name: 'AnswerMain',
        component: () => import(/* webpackChunkName: "product" */ '../views/product/AnswerMain.vue')
      },
      {
        path: '/rechargeRule',
        name: 'rechargeRule',
        component: () => import(/* webpackChunkName: "recharge" */ '../views/recharge/RechargeRule.vue')
      },
      {
        path: '/activeDistributionMember',
        name: 'activeDistributionMember',
        component: () => import(/* webpackChunkName: "recharge" */ '../views/recharge/activeDistributionMember.vue')
      },
      {
        path: '/shareActiveRule',
        name: 'shareActiveRule',
        component: () => import(/* webpackChunkName: "recharge" */ '../views/recharge/shareActiveRule.vue')
      },

      // 系统设置-路径管理
      {
        path: "/urlList",
        name: "urlList",
        component: () =>
          import(/* webpackChunkName: "pc" */ "../views/system/urlList.vue"),
      },
      {
        path: "/rebate",
        name: "rebate",
        component: () =>
          import(/* webpackChunkName: "pc" */ "../views/system/rebate.vue"),
      },
      {
        path: "/noticeList",
        name: "noticeList",
        component: () =>
          import(/* webpackChunkName: "pc" */ "../views/system/noticeList.vue"),
      },
      {
        path: "/mainPic",
        name: "mainPic",
        component: () =>
          import(/* webpackChunkName: "pc" */ "../views/main/mainPic.vue"),
      },
      {
        path: "/userList",
        name: "userList",
        component: () =>
          import(/* webpackChunkName: "pc" */ "../views/user/userList.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  if (to.path === '/login') return next()

  // const tokenStr = window.sessionStorage.getItem('Authorization')
  // if (!tokenStr) {
  //   window.sessionStorage.setItem('timeout', 'true')
  //   return next('/login')
  // }
  return next()
});

export default router;
